DefaultDrawingsLineWidthRepo
Stores information about the current global line width / text size value for new drawings, provides data about the minimum (minLineWidth) and maximum (maxLineWidth) line length / text size.
Default implementation:
/*** Default implementation of [com.devexperts.dxcharts.lib.data.repo.DrawingsLineWidthRepo].** This class provides a default implementation of the [DrawingsLineWidthRepo] interface.** @property getLineWidthCallback Callback function to get the line width for new drawings.* @property setLineWidthCallback Callback function to set the line width for new drawings.* @property minLineWidth Minimum line width. Default value is 1.* @property maxLineWidth Maximum line width. Default value is 5.** @see DrawingsLineWidthRepo*/open class DefaultDrawingsLineWidthRepo(private val getLineWidthCallback: () -> Int,private val setLineWidthCallback: (Int) -> Unit,override val minLineWidth: Int = MIN_LINE_WIDTH,override val maxLineWidth: Int = MAX_LINE_WIDTH) : DrawingsLineWidthRepo {/*** Method to get the line width for new drawings.** @return Line width for new drawings.*/override fun getLineWidth(): Int = getLineWidthCallback()/*** Method to set the line width for new drawings.** @param px The line width in pixels.*/override fun setLineWidth(px: Int) {setLineWidthCallback(px)}/*** Default line width for new drawings when the library is launched.*/companion object {const val DEFAULT_LINE_WIDTH = 1const val MIN_LINE_WIDTH = 1const val MAX_LINE_WIDTH = 5}}
Implementation of the default repository for local storage:
/*** Local storage implementation of [DrawingsLineWidthRepo].** This class provides a local storage implementation of the [DrawingsLineWidthRepo] interface,* using a default line width and storing it locally.** @constructor Creates a LocalStorageDefaultDrawingsLineWidthRepo.*/class LocalStorageDefaultDrawingsLineWidthRepo : DrawingsLineWidthRepo {/*** The line width stored locally.*/private var lineWidth = DefaultDrawingsLineWidthRepo.DEFAULT_LINE_WIDTH/*** The default repository instance using the local line width.*/private val defaultRepo = DefaultDrawingsLineWidthRepo(getLineWidthCallback = ::lineWidth,setLineWidthCallback = ::lineWidth::set,)/*** The minimum line width.*/override val minLineWidth: Int = 1/*** The maximum line width.*/override val maxLineWidth: Int = 5/*** Method to get the line width.** @return The line width.*/override fun getLineWidth(): Int {return defaultRepo.getLineWidth()}/*** Method to set the line width.** @param px The line width in pixels.*/override fun setLineWidth(px: Int) {defaultRepo.setLineWidth(px)}}